package com.eaoa.uc.document.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.eaoa.base.EABaseAction;
import com.eaoa.constants.AttachmentConstants;
import com.eaoa.query.pub.PubDocumentQuery;
import com.eaoa.utils.AttachmentUtils;
import com.eaoa.vo.pub.PubDocument;
import com.stony.core.util.CoreUtils;

public class PubDocumentManageSearchExpandAction extends EABaseAction {

	protected ActionForward doWork(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		Long documentno = CoreUtils.parseLong(request.getParameter("documentno"));

		PubDocument document = PubDocumentQuery.loadByNo(documentno);

		request.setAttribute("document", document);

		if(documentno!=null){
			Map attachments = AttachmentUtils.getAttachmentMap(AttachmentConstants.ATTACHMENTTYPE_DOCUMENT,documentno);
			request.setAttribute("attachments", attachments);
		}
		
		String isSelf="N";
		if(document.getCreateby()!=null && document.getCreateby().equals(getEmployee(request).getAccountno())){
			 isSelf="Y";
		}
		request.setAttribute("isSelf", isSelf);

		return mapping.findForward("success");

	}

}
